
//省市级联
var sheng = Array();
sheng['湖南'] = Array("邵阳","横阳","长沙");
sheng["广东"] = Array("广州","东莞","深圳","中山");

window.onload = function(){
	var shen =  document.getElementById('sheng');
	var shi = document.getElementById('shi');
	for(var i in sheng){
		shen.options.add(new Option(i));
	}
	shen.onchange = function(){
		var index = shen.selectedIndex; // 选中索引
		//var text = shen.options[index].text; // 选中文本
		var value = shen.options[index].value; // 选中值
		//alert(value);
		shi.options.length = 0;
		shi.options.add(new Option("请选择"));
		for(var j in sheng[value]){
			shi.options.add(new Option(sheng[value][j]));
		}
	}
	
	
}





//关闭登陆与注册框
function closeMe(obj) {
	obj.parentNode.parentNode.style.display = 'none';
}
//注册框显示
function reg() {
	var obj = document.getElementById('reg');
	//alert(document.getElementById('reg').offsetLeft);
	var bodyWidth = window.innerWidth | document.body.clientWidth;//浏览器宽度
	//var objWidth = obj.offsetWidth | 500;
	var objWidth = 550;
	//alert(obj.offsetWidth);
	obj.style.left = ((bodyWidth - objWidth)/2)+ "px";
	//alert((bodyWidth - objWidth));
	obj.style.display = 'block';
}
//登陆框显示
function login() {
	
	var obj = document.getElementById('login');
	//alert(document.getElementById('reg').offsetLeft);
	var bodyWidth = window.innerWidth | document.body.clientWidth;//浏览器宽度
	var objWidth = 550;
	//alert(obj.offsetWidth);
	obj.style.left = ((bodyWidth - objWidth)/2)+ "px";
	//alert((bodyWidth - objWidth));
	obj.style.display = 'block';
}
//验证表单
function regSubmit(obj){
	//验证用户名
	var regExp = /^[a-zA-Z]\w{1,20}$/;//用户名是否合法
	var regTxt = obj.uname.value;
	if(!regExp.test(regTxt)){
		alert("用户名不合法");
		return false;
	}
	//验证密码
	regExp = /^[\w!@#\$\%\^\&\*\(\)\/\\]{6,20}$/;//密码是否合法
	regTxt = obj.upwd.value;
	if(!regExp.test(regTxt)){
		alert("密码不合法");
		return false;
	}
	//验证二次密码是否相等
	var pwd2 = obj.upwd1.value;
	if(pwd2 != regTxt){
		alert("重复密码与密码不同!");
		return false;
	}
	//验证邮箱
	regExp = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;//邮箱是否合法
	regTxt = obj.email.value;
	if(!regExp.test(regTxt)){
		alert("邮箱格式不正确!");
		return false;
	}
	
	return true;
	
}



//删除日志AJAX
function delList(obj, i) {
		$.post("ajax/ajax.php", {
			id: i
			,eve: 1
		}, function(data, textStatus, reXML) {
			//alert(data);
			if(data == 1){
				obj.parentElement.parentElement.parentElement.removeChild(obj.parentElement.parentElement);
				//alert(obj.parentElement.parentElement.innerHTML);
			}
			
			//alert(reXML.responseText);
			//$(".content").text(data + textStatus + reXML.responseText); 
		}, "text");
}

function editList(obj, i) {
	var vals = obj.parentElement.parentElement.getElementsByClassName('m2');
	var vals = vals[0].getElementsByTagName('li');
	//alert(val[0].innerHTML);
	//alert(val.length);
	var val = "";
	for(var j = 0 ; j < vals.length ; j++){
		//alert(vals[i].innerText);
		val += vals[j].innerText+"||";
	}
	val = val.substr(0,val.length-2);
	//alert(val);
	
	//进行AJAX修改
		$.post("ajax/ajax.php", {
			id: i
			,eve: 2
			,text: val
		}, function(data, textStatus, reXML) {
			//alert(data);
			if(data == 1){
				//obj.parentElement.parentElement.parentElement.removeChild(obj.parentElement.parentElement);
				//alert(obj.parentElement.parentElement.innerHTML);
				alert("修改成功");
			}else{
				alert(data);
			}
			//alert(reXML.responseText);
			//$(".content").text(data + textStatus + reXML.responseText); 
		}, "text");
}

